<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // console.log(typeof null); // 'object'
    // console.log(typeof undefined); // 'undefined'
    // console.log(typeof {});// 'object'
    // console.log(typeof []);// 'object'
    // console.log(typeof function () { }); // 'function'
    // console.log(typeof 5); // 'number'
    // console.log(typeof '5'); // 'string'
    // console.log(typeof true); // 'boolean'


    // function Person(name) {
    //   this.name = name;
    // }

    // let obj = new Person('eason');

    // console.log(obj instanceof Person);  // true
    // console.log(obj instanceof Object); // true
    // console.log(obj instanceof Array); // false
    // console.log(obj instanceof Function); // false
    // console.log(Array instanceof Function); // true
    // console.log(Person instanceof Function); // true



    function Person(name) {
      this.name = name;
      // this.sex = '男'
    }
    Person.prototype.sex = '男'
    // Object.prototype.sex = '男'

    let obj = new Person('eason');

    // console.log('sex' in obj);// true;

    // console.log(obj.hasOwnProperty('sex')); // false

    // console.log(Object.getPrototypeOf(obj)); //{sex: '男', constructor: ƒ}

    // console.log(Object.getPrototypeOf(obj) === Person.prototype); // true

    // console.log(Object.getPrototypeOf(obj) === obj.__proto__); // true;


    // 判断Person.prototype指向的原型对象是否出现在obj的原型链当中！
    // console.log(Person.prototype.isPrototypeOf(obj)); // true
    // let x = {};
    // console.log(Person.prototype.isPrototypeOf(x)); // false
    // console.log(x);

    // var a = [];
    // var b = {}
    // console.log(Array.isArray(a)); //true

    // console.log(Array.isArray(b)); // fasle

    // let obj1 = { a: 1, b: 2 }
    // let objNew = Object.create(obj1);
    // //指定一个对象作为原型来创建对象。
    // console.log(objNew.__proto__); // obj1.__proto__  :{ a: 1, b: 2 }
    // console.log(objNew.__proto__ === obj1); // true,浅拷贝

    let obj1 = { a: 1, b: 2 }
    // console.log(obj1);
    console.log(Object.prototype.toString.call(obj1)); //[object Object]
    console.log(Object.prototype.toString.call([])); //[object Array]
    console.log(Object.prototype.toString.call(123)); //[object Number]
    console.log(Object.prototype.toString.call("123"))//[object String]
    console.log(Object.prototype.toString.call(true)) //[object Boolean]
    console.log(Object.prototype.toString.call(undefined)) // [object Undefined]
    console.log(Object.prototype.toString.call(null))//[object Null]
    console.log(Object.prototype.toString.call(Symbol())) //[object Symbol]
    console.log(Object.prototype.toString.call(function () { })) //[object Function]


  </script>
</body>

</html>